<?php

/*
 * 2015-8-25 SoChishun Added.
 */

/**
 * 全局配置文件
 * @since 1.0 <2015-8-25> SoChishun Added.
 */
$config = array(
    /* 程序信息 */
    'app_info' => array(
        'full_name' => 'PHP Application Module Market',
        'short_name' => 'PAMM',
        'version' => '1.0',
    ),
    /* 视图配置 */
    'view' => array(
        'page_title' => '无标题',
        'show_header' => true,
    ),
);

/**
 * 返回用户提交的参数
 * @param string $name
 * @param string $defv
 * @return string
 * @since 1.0 <2015-8-25> SoChishun Added.
 */
function I($name, $defv = '') {
    if (isset($_POST[$name])) {
        return $_POST[$name];
    }
    if (isset($_GET[$name])) {
        return $_GET[$name];
    }
    return $defv;
}

/**
 * 收集用户提交的参数
 * @param array $configs
 * @param array $data
 * @since 1.0 <2015-8-25> SoChishun Added.
 */
function P($configs, &$data = false) {
    foreach ($configs as $field => $config) {
        $value = I($field);
        switch ($config['validate']) {
            case 'require':
                if (!isset($value)) {
                    $errs[] = $config['err'];
                    continue;
                }
                break;
        }
        $data[$field] = $value;
    }
}
